﻿using System;

namespace Qing.QLoggers
{
    public class QLogInfo
    {
        private DateTime? time = null;
        public DateTime Time { set { time = value; } get { if (time == null) time = DateTime.Now; return time.Value; } }
        public string FormatTime { get { return Time.ToString("yyyy-MM-dd HH:mm:ss:fff"); } }

        private QLogLevel level = QLogLevel.Info;
        public QLogLevel Level { set { level = value; } get { return level; } }

        private int? code = null;
        public int? Code { set { code = value; } get { return code; } }
        public string FormatCode { get { return code.Value + ""; } }

        public string Msg { set; get; }

        public string Sender { set; get; }

        public string[] Parameters { set; get; }
        public string FormatPatameters { get { if (Parameters == null) return null; return string.Concat(Parameters); } }

        public Exception E { set; get; }
        public string FormatE { get { if (E == null) return null; return E.Message + E.StackTrace; } }

        public string Tag { set; get; }

        public override string ToString()
        {
            return string.Format("{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\t\t{5}\t\t{6}", FormatTime, FormatCode, Msg, Sender, FormatPatameters, FormatE, Tag);
        }
    }
}
